<%--
  Created by IntelliJ IDEA.
  User: oldliu
  Date: 2022-02-18
  Time: 17:20
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>登录</title>
    <script>
        //iframe,防止被框架套住
        if(self!=parent){
            parent.location=self.location;
        }
    </script>
</head>
<body>
  用户登录
  <p style="color: red">
     ${msg}
  </p>
  <%
      Object o_=session.getAttribute("USER_LOGIN");
      if (o_==null){
  %>
 <%
     Cookie cr[]=request.getCookies();
     Cookie cname=null;
     for(int i=0;cr!=null &&i<cr.length;i++){
         if(cr[i].getName().equals("loginname")){
             cname=cr[i];
             break;
         }
     }
     String yourname="";
     if(cname!=null)
         yourname=cname.getValue();
 %>
<form action="loginServlet" method="post">
    <input type="text" name="userName" required placeholder="用户名" value="<%=yourname%>"/>
    <input type="password" name="userPass" required placeholder="用户密码"/>
<input type="submit" value="登录"/>
</form>
<%
    }else {
%>
<a href="main.jsp">主页</a>
<%
    }
%>
</body>
</html>
